package mysql

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Name     string `gorm:"type:varchar(20);not null;comment:'昵称'"`
	Phone    string `gorm:"type:varchar(11);not null;comment:'手机号'"`
	Password string `gorm:"type:varchar(32);not null;comment:'密码'"`
}

func GetUser(phone string) (result *User, err2 error) {
	err2 = DB.Debug().Where("phone = ?", phone).Limit(1).Find(&result).Error
	if err2 != nil {
		return nil, err2
	}
	return
}

func CreateUser(user *User) error {
	return DB.Debug().Create(&user).Error
}
